<appview> Tag
Description: |
Use the appview tag to embed other Chrome Apps within your
Chrome App. (see Usage).
|
Availability: |
Since Chrome 43.
|
Permissions: |
"appview"
|
Usage
Use the appview
tag to embed other Chrome Apps within your Chrome
App.
The appview
runs in a separate process from your app, it doesn't
inherit the same permissions and is only allowed to interact with your app
through asynchronous APIs.
Not all apps can be embedded; apps have to explicitly allow themselves to be
embedded.
Preparing your app to be embedded
To allow your app to be embedded into another app, you need to add a listener to your app's background page:
chrome.app.runtime.onEmbedRequested.addListener(function(request) { // Allows the embedder to embed foo.html. request.allow("foo.html"); });
Embedding another app
To embed another Chrome App in your app, add the appview
tag to
your app's embedder page (this is the app page that will display the
embedded app) and use the connect API to request the embedding of the other
app.
// Creates an <appview> element. var appview = document.createElement("appview"); // Appends the element to the document body. document.body.appendChild(appview); // Connects the appview to appToEmbed. // appToEmbed is the id of the app you are trying to embed. appview.connect(appToEmbed);
Summary
Types | |
---|---|
EmbedRequest | |
Methods | |
connect −
<appview>.connect(string app, any data, function callback)
|
Types
EmbedRequest
properties | ||||||||
---|---|---|---|---|---|---|---|---|
string | embedderId |
The ID of the app that sent the embedding request. |
||||||
object | data |
Optional developer specified data that the app to be embedded can use when making an embedding decision. |
||||||
function | allow |
Allows the embedding request.
|
||||||
function | deny |
Prevents the embedding request. |
Methods
connect
<appview>.connect(string app, any data, function callback)
Requests another app to be embedded.
Parameters | |||||
---|---|---|---|---|---|
string | app |
The extension id of the app to be embedded. |
|||
any | (optional) data |
Optional developer specified data that the app to be embedded can use when making an embedding decision. |
|||
function | (optional) callback |
An optional function that's called after the embedding request is completed. If you specify the callback parameter, it should be a function that looks like this: function(boolean success) {...};
|